package com.example.bookkeepingelf.business.listener.main;


import android.content.Intent;
import android.view.View;

import androidx.room.RoomDatabase;

import com.example.bookkeepingelf.MainActivity;
import com.example.bookkeepingelf.base.listener.AbstractActivityViewListener;
import com.example.bookkeepingelf.base.utils.AsyncUtils;
import com.example.bookkeepingelf.business.database.AppDatabase;
import com.example.bookkeepingelf.business.database.dao.UserDao;
import com.example.bookkeepingelf.business.database.entity.User;

/**
 * 主界面的按钮点击事件监听器
 */
public class MainActivitySpikeButtonListener extends AbstractActivityViewListener<MainActivity> {

    private UserDao userDao;


    /**
     * 构造方法
     * @param activity 宿主Activity
     */
    public MainActivitySpikeButtonListener(MainActivity activity) {
        super(activity);
    }

    /**
     * 初始化
     * @param database
     */
    @Override
    protected void initialization(RoomDatabase database) {
        AppDatabase appDatabase = (AppDatabase)database;
        this.userDao = appDatabase.userDao();
    }

    /**
     * 点击事件
     * @param view
     */
    @Override
    public void onClick(View view) {
        MainActivity hostActivity = this.getHostActivity();
        AsyncUtils.runSingle(() -> {
//            this.userDao.insert(new User(3,"123456"));
        }, true);

        // 如果是按钮1
    }





}
